package com.beiing.tianshuai.tianshuai.huodong.model;

import com.beiing.tianshuai.tianshuai.dongtai.CallBack;
import com.beiing.tianshuai.tianshuai.entity.HuoDongItemBean;
import com.beiing.tianshuai.tianshuai.network.DataManager;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.observers.DisposableObserver;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by magikliu on 2017/9/8.
 */

public class HuoDongAllModel implements HuoDongAllModelImpl {

    @Override
    public void getAllHuoDong(int firstRow, int listRows, final CallBack callBack) {
        DisposableObserver<HuoDongItemBean> observer = new DisposableObserver<HuoDongItemBean>() {
            @Override
            public void onNext(@NonNull HuoDongItemBean huoDongItemBean) {
                callBack.result(huoDongItemBean);
            }

            @Override
            public void onError(@NonNull Throwable e) {
                callBack.error(e);
            }

            @Override
            public void onComplete() {

            }
        };

        DataManager.getAllHuoDong(firstRow, listRows)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }
}
